
package com.yimixian.app.cart;

import com.yimixian.app.R;
import com.yimixian.app.adapter.CartItemAdapter;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.TextView;

import butterknife.ButterKnife;
import butterknife.InjectView;

public class CartNewFreebieGoodsItemView extends CartNewGoodsItemView {

    @InjectView(R.id.freebie_title_text)
    TextView mFreebieTitleText;
    private String mFreebieTitle;

    public CartNewFreebieGoodsItemView(Context context, CartItemAdapter cartItemAdapter) {
        super(context, cartItemAdapter);
    }

    public CartNewFreebieGoodsItemView(Context context, String freebieTitle,
            CartItemAdapter cartItemAdapter) {
        super(context, cartItemAdapter);
        mFreebieTitle = freebieTitle;
    }

    public CartNewFreebieGoodsItemView(Context context, AttributeSet attrs,
            CartItemAdapter cartItemAdapter) {
        super(context, attrs, cartItemAdapter);
    }

    public CartNewFreebieGoodsItemView(Context context, AttributeSet attrs, int defStyle,
            CartItemAdapter cartItemAdapter) {
        super(context, attrs, defStyle, cartItemAdapter);
    }

    @Override
    protected void init() {
        LayoutInflater.from(getContext()).inflate(R.layout.cart_freebie_goods_item_view, this);
        setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.WRAP_CONTENT));
        if (!TextUtils.isEmpty(mFreebieTitle)) {
            mFreebieTitleText.setText(mFreebieTitle);
        }
        ButterKnife.inject(this);

    }

    public void hideTitleView() {
        if(mFreebieTitleText != null) {
            mFreebieTitleText.setVisibility(View.GONE);
        }
    }
}
